﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VM.BLL.Member;
using VM.Common.Result;
using VM.Entity.EntityMap.Member;
using VM.Entity.EntityMap.Region;
using VM.IBLL.Member;
using VM.IBLL.Region;
using VM.WebCore.Jwt;
using VM.WebCore.SwaggerExtend;
using VM.Wechat;

namespace VM.WebAPI.Controllers
{
    /// <summary>
    /// 区域相关控制器
    /// </summary>
    [Route("api/region")]
    [ApiController]
    public class RegionController : ControllerBase
    {
        private readonly IRegionBLL _IRegionBLL;
        private readonly IJWTService _IJWTService;
        private readonly IHttpContextAccessor _HttpContextAccessor;


        public RegionController(IJWTService iJWTService, IRegionBLL iRegionBLL, IHttpContextAccessor httpContextAccessor)
        {

            _IRegionBLL = iRegionBLL;
            _IJWTService = iJWTService;
            _HttpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 根据省市县名称获取省市县（区）的编码
        /// </summary>
        /// <param name="Province">省名字</param>
        /// <param name="City">市</param>
        /// <param name="County">县</param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("getRegionCodes")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiDataResult<List<sys_region>> getRegionCodes(string Province, string City, string County)
        {

            //校验验证码是否可用，如果可用，返回true
            ApiDataResult<List<sys_region>> Res = _IRegionBLL.getRegionCodeByName(Province, City, County);
            return Res;


        }


    }
}
